//@author A0105735J
#include "CommandAdd.h"

CommandAdd::CommandAdd(){
	type = CommandTypeAdd;
}

CommandAdd::~CommandAdd(void){}

//@author A0105730U
void CommandAdd::setEvent(Event* tempEvent){
	theEvent = tempEvent;
}

//@author A0105730U
Feedback CommandAdd::execute(Receiver* receiver){
	Logger::instance()->LogMessage("trying to add one event");	
	return receiver->addCommand(theEvent);
}

//@author A0105730U
Feedback CommandAdd::undo(Receiver* receiver){
	Logger::instance()->LogMessage("trying to delete one event which was added just now");	
	// find the targetEvent based on searchID
	Event* targetEvent = receiver->getTargetEvent(theEvent->getSearchID(),2);
	std::vector<int> id;
	id.push_back(targetEvent->getDisplayID());
	return receiver->deleteCommand(id);
}